<?php

$image_folder = $this->session->userdata('image_folder');

$category_img_path = UPLOAD_FOLDER_URL. CATEGORY_IMAGE_URL;
$temp_img_path = UPLOAD_FOLDER_URL. 'public/' . $image_folder . '/' . TEMP_FOLDER_URL;
$aCateImage = upload_modal_get($category_img_path);
$aTempImage = upload_modal_get($temp_img_path, $image_folder);

?>
<div id="modal-change-img" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalChangeImg" aria-hidden="true">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel">Thay đổi hình đại diện</h4>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div class="col-md-10 col-md-offset-2 col-xs-12">
                        <form id="frm-upload-img" method="post" action="<?php echo admin_page_url('hinh-anh/tai-len'); ?>" enctype="multipart/form-data">
                            <div class="form-group col-md-7 col-xs-12">
                                <div class="input-group">
                                    <input type="file" name="userfile" class="form-control" />
                                    <span class="input-group-btn">
                                        <button id="btn-change-img" class="btn btn-primary">
                                            <i class="glyphicon glyphicon-arrow-up"></i>
                                            Tải lên
                                            <span class="percent hidden">0%</span>
                                        </button>
                                    </span>
                                </div>
                            </div>
                            <div class="form-group col-md-5 col-xs-12">
                                <button type="button" class="btn btn-success btn-choose-image"><i class="glyphicon glyphicon-ok-sign"></i> Chọn</button>
                                <button type="button" class="btn btn-default btn-close-image"><i class="glyphicon glyphicon-remove-sign"></i> Huỷ</button>
                            </div>
                        </form>
                    </div>
                    <p class="image-section"><i class="glyphicon glyphicon-chevron-right"></i> Đang được sử dụng</p>
                    <ul class="image-list clearPad">
                        <?php foreach($aCateImage as $img) { ?>
                        <li>
                            <a href="<?php echo upload(CATEGORY_IMAGE_URL .$img); ?>" class="thumbnail img-block-edit category-img-block clearMgr" data-name='<?php echo $img; ?>' data-folder='<?php echo CATEGORY_IMAGE_URL; ?>' data-url-remove="<?php echo admin_page_url('hinh-anh/xoa'); ?>" >
                                <img class="media-object" src="<?php echo upload(CATEGORY_IMAGE_URL .$img); ?>" />
                            </a>
                        </li>
                        <?php } ?>
                    </ul>
                    <p class="image-section"><i class="glyphicon glyphicon-chevron-right"></i> Đã tải lên</p>
                    <ul class="image-list clearPad">
                        <?php foreach($aTempImage as $img) { ?>
                        <li>
                            <a href="<?php echo temp_image($img, $image_folder); ?>" class="thumbnail img-block-edit category-img-block clearMgr" data-url-remove="<?php echo admin_page_url('hinh-anh/xoa'); ?>" data-name='<?php echo $img; ?>' data-folder='<?php echo TEMP_FOLDER_URL; ?>' >
                                <img class="media-object" src="<?php echo temp_image($img, $image_folder, false, true); ?>" />
                            </a>
                        </li>
                        <?php } ?>
                    </ul>
                    <ul>
                        <li class="hidden" id="temp-img-block">
                            <a href="#" class="thumbnail img-block-edit category-img-block clearMgr" data-url-remove="<?php echo admin_page_url('hinh-anh/xoa'); ?>" data-folder='<?php echo TEMP_FOLDER_URL; ?>' data-name=''>
                                <img class="media-object" src="" />
                            </a>
                        </li>
                    </ul>
                    <div class="clearfix"></div>
                </div>
            </div>
        </div>
    </div>
</div>